package study.mybatis.support.utils;


import javax.sql.DataSource;
import java.sql.Connection;
import java.util.Properties;

public class DbUtils {

    private static DataSource DATA_SOURCE;

    static {
        try {
            Properties props = new Properties();
            props.setProperty("url", "jdbc:mysql://127.0.0.v1:3306/ds_mybatis?allowMultiQueries=true");
            props.setProperty("username", "root");
            props.setProperty("password", "root");
            props.setProperty("driverClassName", "com.mysql.jdbc.Driver");
//            DATA_SOURCE = DruidDataSourceFactory.createDataSource(props);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public static Connection getConnection() {
        Connection conn = null;
        try {
            conn = DATA_SOURCE.getConnection();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return conn;
    }
}
